package fileshare.datastructure;
/**
 * String ipaddress;
*	int portnumber;
	*	String peeridinfo;
		int filestat;
		int index;
 * @author Administrator
 *put the information read from the peerinfo.frg into an object
 *each object contains one line
 */
public class ipinfo
	{
	
		public String ipaddress;//cise.ufl.edu
		public int portnumber;//6789
		public String peeridinfo;//1001
		public int filestat;
		public int index;//1,2,3....6
		/**
		 * 
		 * @param s the original peer information of a certain peer in the peerinfo.rpg "1001 localhost 8008" for example 
		 * @param cou the assigned index "1","2",,,,,,
		 */
		public ipinfo(String s,int cou)
		{
			index=cou;
			int length=s.length();
			String peerid="";
			String add="";
			String stat="";
			String po="";
			int tick=1;
			for(int i=0;i<length;i++)
			{
				char c=s.charAt(i);
				if(c!=' '&&tick==1)
					peerid=peerid+c;
				else if(c==' '&&tick==1)
				{
					tick=2;
					continue;
				}
				if(c!=' '&&tick==2)
					add=add+c;
				else if(c==' '&&tick==2)
				{
					tick=3;
					continue;
				}
				if(c!=' '&&tick==3)
					po=po+c;
				else if(c==' '&&tick==3)
				{
					tick=4;continue;
				}
				if(c!=' '&&tick==4)
					stat=stat+c;
				
				
			}
			ipaddress=add;
			portnumber = Integer.parseInt(po,10);
			filestat=Integer.parseInt(stat,10);
			peeridinfo=peerid;
			
			
		}
		
		
	}